package byggeTegning.husGeometri;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;

import javax.media.j3d.Group;
import javax.vecmath.Color3f;

import byggeTegning.geometry.Point3D;
import byggeTegning.geometry.TransformedGroup3D;


// ***************************************************************************
// *** CLASS: SalTakEnkelSki
// ***************************************************************************
public class SalTakEnkelSki extends BjelkeLag
{
  SalTakEndeBord vannBord;
  SalTakEndeBord takSki;
  double takskiHoyde=0.10;
  double takskiUtspring=0.03; // Utspring
  double takskiSkjevhet=0; // Skias skjevhet i front
    
  public SalTakEnkelSki
  (String ident,Point3D p0,double tanTakvinkel,double width,double height,double depth,boolean north)
  { super(ident,p0,width,height,depth);
    // VannBord
    { double vannBordHoyde=0.025; // 2.5 cm
      double vannBordUtspring=takskiUtspring+takskiSkjevhet+0.03;
      double vannBordSkjevhet=0;
      Point3D pVannBord=p0.addY(takskiHoyde-0.02).addX(width/2-0.05);
      this.vannBord=
        new SalTakEndeBord(ident,pVannBord,tanTakvinkel,0.10,height,depth,
              vannBordHoyde,vannBordUtspring,vannBordSkjevhet);
    }          
    // TakSki
    { double takSkiHoyde=0.10; // 10 cm
      double takSkiUtspring=takskiUtspring+takskiSkjevhet/3;
      double takSkiSkjevhet=takskiSkjevhet;
      Point3D pTakSki=p0.addY(-0.03).addX((north)?width:-width);
      this.takSki=
        new SalTakEndeBord(ident,pTakSki,tanTakvinkel,width,height,depth,
              takSkiHoyde,takSkiUtspring,takSkiSkjevhet);
    }          
  }
  
  // ***************************************************************************
  // *** METHOD: getModel3D
  // ***************************************************************************
  public /*abstract*/ Group getModel3D(Color3f c)
  { TransformedGroup3D tg=new TransformedGroup3D();
    tg.addChild(vannBord.getModel3D(c));
    tg.addChild(takSki.getModel3D(c));
    return(tg);
  }  

  public void drawProjection(int direction,Graphics2D g,Point2D.Double origo2D,double scale,Color c)
  { takSki.drawProjection(direction,g,origo2D,scale,c);
    vannBord.drawProjection(direction,g,origo2D,scale,c);
  }  

}  
